Method and apparatus for controlling sending of heartbeat signal

ABSTRACT

A method and an apparatus for controlling sending of a heartbeat signal are provided. The method includes acquiring a target push delay corresponding to all target applications; sending the target push delay to a push server; receiving a first heartbeat signal control time sent by the push server and corresponding to the target push delay; and sending a heartbeat signal to the push server at an interval of the first heartbeat signal control time. According to the embodiments of the present invention, a first heartbeat signal control time may be determined according to an acquired target push delay corresponding to all target applications, and the first heartbeat signal control time may be adjusted according to a target application, so that a push client can send a heartbeat signal to a push server at an interval of the first heartbeat signal control time, to maintain a Push connection.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Application No.PCT/CN2013/074797, filed on Apr. 26, 2013, which is hereby incorporatedby reference in its entirety.

TECHNICAL FIELD

The present invention relates to the communications field, and inparticular, to a method and an apparatus for controlling sending of aheartbeat signal.

BACKGROUND

With the development of services, such as Internet, mobile network,digital television, and mobile multimedia broadcasting services, Push,which emerged earliest as a push instruction in the computer programminglanguage, has developed to be a client/server mechanism-based technologyin which a server proactively sends information to a client. InternetProtocol (IP) Push refers to an Hypertext Transfer Protocol (HTTP)-basedtechnology in which a server pushes a message to a mobile device throughan IP network.

To enable a server to push information to a mobile device in real time,a connection is established between the mobile device and the server. Ifthere is no push message exchange for a long time, the connection may bedisconnected, and consequently, the push message cannot be pushed to themobile device in time. Therefore, to keep stability of the connection,the mobile device needs to send a heartbeat signal to the server atintervals, so as to keep the connection in an active state. In the priorart, after a connection is established between a mobile device and aserver, the mobile device sends a heartbeat signal to the server at afixed time interval, that is, the mobile device sends the heartbeatsignal to the server at a fixed frequency. If a time interval forsending the heartbeat signal is too long, the connection may bedisconnected due to interference, such as network quality or a firewall,causing that a push message cannot be pushed by the server to the mobiledevice in time. If the time interval for sending the heartbeat signal istoo short, the mobile device needs to enable a network constantly, so asto send the heartbeat signal to the server, which increases batterypower consumption of the mobile device and increases network traffic ofthe mobile device.

SUMMARY

Embodiments of the present invention provide a method and an apparatusfor controlling sending of a heartbeat signal, so as to ensure stabilityof a Push connection and effectively reduce power consumption andnetwork data traffic.

A first aspect of the embodiments of the present invention provides amethod for controlling sending of a heartbeat signal, includingacquiring a target push delay corresponding to all target applications;sending the target push delay to a push server; receiving a firstheartbeat signal control time sent by the push server and correspondingto the target push delay; and sending a heartbeat signal to the pushserver at an interval of the first heartbeat signal control time.

In a first possible implementation manner of the first aspect, theacquiring a target push delay corresponding to all target applicationsincludes, if a quantity of all the target applications is one, acquiringa push delay of the target application, and using the push delay of thetarget application as the target push delay; or if a quantity of all thetarget applications is at least two, acquiring push delays of all thetarget applications, and using a shortest push delay in all the pushdelays as the target push delay.

With reference to the first aspect or the first possible implementationmanner of the first aspect, in a second possible implementation mannerof the first aspect, after the sending a heartbeat signal to the pushserver at an interval of the first heartbeat signal control time, themethod further includes, if it is detected that the heartbeat signalfails to be sent, reporting a sending failure rate to the push server;receiving a second heartbeat signal control time that is returned by thepush server according to the sending failure rate and the target pushdelay, where the second heartbeat signal control time is shorter thanthe first heartbeat signal control time; and sending a heartbeat signalto the push server at an interval of the second heartbeat signal controltime.

A second aspect of the embodiments of the present invention provides amethod for controlling sending of a heartbeat signal, includingreceiving a target push delay sent by a push client and corresponding toall target applications; acquiring a first heartbeat signal control timecorresponding to the target push delay; sending the first heartbeatsignal control time to the push client; and receiving a heartbeat signalthat is sent by the push client at an interval of the first heartbeatsignal control time.

In a first possible implementation manner of the second aspect, afterthe receiving a heartbeat signal that is sent by the push client at aninterval of the first heartbeat signal control time, the method furtherincludes receiving a sending failure rate that is reported by the pushclient after detecting that the heartbeat signal fails to be sent;acquiring a second heartbeat signal control time that corresponds to thesending failure rate and the target push delay; sending the secondheartbeat signal control time to the push client, where the secondheartbeat signal control time is shorter than the first heartbeat signalcontrol time; and receiving a heartbeat signal that is sent by the pushclient at an interval of the second heartbeat signal control time.

With reference to the second aspect or the first possible implementationmanner of the second aspect, in a second possible implementation mannerof the second aspect, the acquiring a first heartbeat signal controltime corresponding to the target push delay includes acquiring the firstheartbeat signal control time according to a network standard, a pushsuccess rate, and the target push delay, where the first heartbeatsignal control time is a longest heartbeat signal control time,corresponding to the target push delay, in a current network standardand when a preset push success rate is met.

With reference to the first possible implementation manner of the secondaspect, in a third possible implementation manner of the second aspect,the acquiring a second heartbeat signal control time that corresponds tothe sending failure rate and the target push delay includes acquiringthe second heartbeat signal control time according to a networkstandard, a push success rate, the sending failure rate, and the targetpush delay, where the second heartbeat signal control time is a longestheartbeat signal control time, corresponding to the sending failure rateand the target push delay, in a current network standard and when apreset push success rate is met.

A third aspect of the embodiments of the present invention provides anapparatus for controlling sending of a heartbeat signal, including atarget push delay acquiring module configured to acquire a target pushdelay corresponding to all target applications; a target push delaysending module configured to send the target push delay acquired by thetarget push delay acquiring module to a push server; a first receivingmodule configured to receive a corresponding first heartbeat signalcontrol time that is returned by the push server according to thereceived target push delay sent by the target push delay sending module;and a first heartbeat-signal sending module configured to send aheartbeat signal to the push server at an interval of the firstheartbeat signal control time according to the first heartbeat signalcontrol time received by the first receiving module.

In a first possible implementation manner of the third aspect, thetarget push delay acquiring module includes a first acquiring unitconfigured to, when a quantity of all the target applications is one,acquire a push delay of the target application, and use the push delayof the target application as the target push delay; and a secondacquiring unit configured to, when a quantity of all the targetapplications is at least two, acquire push delays of all the targetapplications, and use a shortest push delay in all the push delays asthe target push delay.

With reference to the third aspect or the first possible implementationmanner of the third aspect, in a second possible implementation mannerof the third aspect, the apparatus further includes a sending failurerate reporting module configured to, when detecting that the heartbeatsignal fails to be sent, report a sending failure rate to the pushserver; a second receiving module configured to receive a secondheartbeat signal control time that is returned by the push serveraccording to the sending failure rate reported by the sending failurerate reporting module and the target push delay sent by the target pushdelay sending module, where the second heartbeat signal control time isshorter than the first heartbeat signal control time; and a secondheartbeat-signal sending module configured to send a heartbeat signal tothe push server at an interval of the second heartbeat signal controltime according to the second heartbeat signal control time received bythe second receiving module.

A fourth aspect of the embodiments of the present invention provides anapparatus for controlling sending of a heartbeat signal, including atarget push delay receiving module configured to receive a target pushdelay sent by a push client and corresponding to all targetapplications; a first-heartbeat-signal-control-time acquiring moduleconfigured to acquire a first heartbeat signal control timecorresponding to the target push delay received by the target push delayreceiving module; a first sending module configured to send the firstheartbeat signal control time acquired by thefirst-heartbeat-signal-control-time acquiring module to the push client;and a first heartbeat-signal receiving module configured to receive aheartbeat signal that is sent by the push client at an interval of thefirst heartbeat signal control time according to the received firstheartbeat signal control time sent by the first sending module.

In a first possible implementation manner of the fourth aspect, theapparatus further includes a sending failure rate receiving moduleconfigured to receive a sending failure rate that is reported by thepush client after detecting that the heartbeat signal fails to be sent;a second-heartbeat-signal-control-time acquiring module configured toacquire a second heartbeat signal control time that corresponds to thesending failure rate received by the sending failure rate receivingmodule and the target push delay received by the target push delayreceiving module; a second sending module configured to send the secondheartbeat signal control time acquired by thesecond-heartbeat-signal-control-time acquiring module to the pushclient, where the second heartbeat signal control time is shorter thanthe first heartbeat signal control time; and a second heartbeat-signalreceiving module configured to receive a heartbeat signal that is sentby the push client at an interval of the second heartbeat signal controltime according to the received second heartbeat signal control time sentby the second sending module.

With reference to the fourth aspect or the first possible implementationmanner of the fourth aspect, in a second possible implementation mannerof the fourth aspect, when the first-heartbeat-signal-control-timeacquiring module acquires the first heartbeat signal control timecorresponding to the target push delay, thefirst-heartbeat-signal-control-time acquiring module is configured toacquire the first heartbeat signal control time according to a networkstandard, a push success rate, and the target push delay, where thefirst heartbeat signal control time is a longest heartbeat signalcontrol time, corresponding to the target push delay, in a currentnetwork standard and when a preset push success rate is met.

With reference to the first possible implementation manner of the fourthaspect, in a third possible implementation manner of the fourth aspect,when the second-heartbeat-signal-control-time acquiring module acquiresthe second heartbeat signal control time that corresponds to the sendingfailure rate and the target push delay, thesecond-heartbeat-signal-control-time acquiring module is configured toacquire the second heartbeat signal control time according to a networkstandard, a push success rate, the sending failure rate, and the targetpush delay, where the second heartbeat signal control time is a longestheartbeat signal control time, corresponding to the sending failure rateand the target push delay, in a current network standard and when apreset push success rate is met.

A fifth aspect of the embodiments of the present invention provides aterminal, including a first processor, a first receiver, and a firstsender, where the first processor is configured to acquire a target pushdelay corresponding to all target applications; the first sender,connected to the processor, is configured to send the target push delayto a push server; and the first receiver, connected to the firstprocessor, is configured to receive a first heartbeat signal controltime sent by the push server and corresponding to the target push delay,where the first processor is further configured to send a heartbeatsignal to the push server through the first sender at an interval of thefirst heartbeat signal control time.

In a first possible implementation manner of the fifth aspect, when thefirst processor acquires the target push delay corresponding to all thetarget applications, the first processor is configured to, if a quantityof all the target applications is one, acquire a push delay of thetarget application, and use the push delay of the target application asthe target push delay; or if a quantity of all the target applicationsis at least two, acquire push delays of all the target applications, anduse a shortest push delay in all the push delays as the target pushdelay.

With reference to the fifth aspect or the first possible implementationmanner of the fifth aspect, in a second possible implementation mannerof the fifth aspect, the first processor is further configured to, aftersending the heartbeat signal to the push server through the first senderat an interval of the first heartbeat signal control time, if detectingthat the heartbeat signal fails to be sent, report a sending failurerate to the push server through the first sender; the first receiver isfurther configured to receive a second heartbeat signal control timethat is returned by the push server according to the sending failurerate and the target push delay, where the second heartbeat signalcontrol time is shorter than the first heartbeat signal control time;and the first processor is further configured to send a heartbeat signalto the push server through the first sender at an interval of the secondheartbeat signal control time.

A sixth aspect of the embodiments of the present invention provides aserver, including a second processor, a second receiver, and a secondsender, where the second receiver is configured to receive a target pushdelay sent by a push client and corresponding to all targetapplications; the second processor, connected to the second receiver, isconfigured to acquire a first heartbeat signal control timecorresponding to the target push delay; and the second sender, connectedto the second processor, is configured to send the first heartbeatsignal control time to the push client, where the second receiver isfurther configured to receive a heartbeat signal that is sent by thepush client at an interval of the first heartbeat signal control time.

In a first possible implementation manner of the sixth aspect, thesecond receiver is further configured to receive a sending failure ratethat is reported by the push client after detecting that the heartbeatsignal fails to be sent; the second processor is further configured toacquire a second heartbeat signal control time that corresponds to thesending failure rate and the target push delay; the second sender isfurther configured to send the second heartbeat signal control time tothe push client, where the second heartbeat signal control time isshorter than the first heartbeat signal control time; and the secondreceiver is further configured to receive a heartbeat signal that issent by the push client at an interval of the second heartbeat signalcontrol time.

With reference to the sixth aspect or the first possible implementationmanner of the sixth aspect, in a second possible implementation mannerof the sixth aspect, when the second processor acquires the firstheartbeat signal control time corresponding to the target push delay,the second processor is configured to acquire the first heartbeat signalcontrol time according to a network standard, a push success rate, andthe target push delay, where the first heartbeat signal control time isa longest heartbeat signal control time, corresponding to the targetpush delay, in a current network standard and when a preset push successrate is met.

With reference to the first possible implementation manner of the sixthaspect, in a third possible implementation manner of the sixth aspect,when the second processor acquires the second heartbeat signal controltime that corresponds to the sending failure rate and the target pushdelay, the second processor is configured to acquire the secondheartbeat signal control time according to a network standard, a pushsuccess rate, the sending failure rate, and the target push delay, wherethe second heartbeat signal control time is a longest heartbeat signalcontrol time, corresponding to the sending failure rate and the targetpush delay, in a current network standard and when a preset push successrate is met.

According to the embodiments of the present invention, a first heartbeatsignal control time can be determined according to an acquired targetpush delay corresponding to all target applications, and the firstheartbeat signal control time can be adjusted according to a targetapplication, so that a push client can send a heartbeat signal to a pushserver at an interval of the first heartbeat signal control time,thereby ensuring stability of a Push connection, and effectivelyreducing power consumption and network data traffic.

BRIEF DESCRIPTION OF THE DRAWINGS

To describe the technical solutions in the embodiments of the presentinvention more clearly, the following briefly introduces theaccompanying drawings required for describing the embodiments. Theaccompanying drawings in the following description show merely someembodiments of the present invention, and a person of ordinary skill inthe art may still derive other drawings from these accompanying drawingswithout creative efforts.

FIG. 1 is a schematic structural diagram of an apparatus for controllingsending of a heartbeat signal according to an embodiment of the presentinvention;

FIG. 2 is a schematic structural diagram of another apparatus forcontrolling sending of a heartbeat signal according to an embodiment ofthe present invention;

FIG. 3 is a schematic structural diagram of a system for controllingsending of a heartbeat signal according to an embodiment of the presentinvention;

FIG. 4 is a flowchart of a method for controlling sending of a heartbeatsignal according to an embodiment of the present invention;

FIG. 5 is a schematic structural diagram of a terminal according to anembodiment of the present invention; and

FIG. 6 is a schematic structural diagram of a server according to anembodiment of the present invention.

DETAILED DESCRIPTION

To make the objectives, technical solutions, and advantages of thepresent invention clearer and more comprehensible, the following furtherdescribes the present invention in detail with reference to theaccompanying drawings and embodiments.

According to a method and an apparatus for controlling sending of aheartbeat signal provided by embodiments of the present invention, apush client acquires a target push delay corresponding to all targetapplications; the push client sends the target push delay to a pushserver; the push server receives the target push delay sent by the pushclient and corresponding to all the target applications; the push serveracquires a first heartbeat signal control time corresponding to thetarget push delay; the push server sends the first heartbeat signalcontrol time to the push client; the push client receives the firstheartbeat signal control time; and the push client sends a heartbeatsignal to the push server at an interval of the first heartbeat signalcontrol time. A heartbeat signal control time can be adjusted accordingto a target application, so that the push client can send a heartbeatsignal to the push server at an interval of the heartbeat signal controltime, which ensures stability of a Push connection, thereby furtherimproving timeliness of push message pushing and enhancing userexperience. Furthermore, because a length of the heartbeat signalcontrol time can be adjusted according to the target application,unnecessary power consumption and network data traffic can be reduced.

The push server refers to a server that can provide a Push service. ThePush server is connected to the Push client through an IP network, forexample, a Transmission Control Protocol (TCP) connection may beestablished between the Push client and the Push server. To keepstability of the connection, the Push client sends a heartbeat signal tothe Push server at intervals, to keep the connection in an active stateand keep the stability of the Push connection. The Push server may pusha message to the Push client at any time by using the Push connection.

The push client refers to a terminal that subscribes to a Push serviceduring network registration, such as a mobile phone, a tablet computer,a digital television terminal, or a set top box. The Push clientincludes a Push proxy and at least one target application. The targetapplication may be an application program that is included in the pushclient and that successfully registers application information with thePush proxy, where the registered application information includes atarget application name and a push-acceptable signal delay. The targetapplication may be, for example, a telephone application of a mobilephone that successfully registers application information with the Pushproxy, a game application of a tablet computer that successfullyregisters application information with the Push proxy, or a financeapplication of a digital television that successfully registersapplication information with the Push proxy, that is, the targetapplication is an application program that can receive a Push message.The Push proxy is a communication proxy that is used as a proxy for thetarget application to send a target push delay, a heartbeat signal, orthe like, to the push server, or is used as a proxy for the targetapplication to receive a push message, a target push delay, or the like,from the push server.

After the connection is established between the Push server and the Pushclient, the application program needs to apply to the Push server forregistration, and after the registration succeeds, the Push server mayreceive a heartbeat signal sent by the Push client, or send a pushmessage to the target application. The target application applies to thePush server for a push target address identifier, where the push targetaddress identifier is a unique identifier of a Push target address andis used to identify to which application of a specific device of theclient a message is pushed. Steps for the application program to applyto the Push server for registration are as follows.

The application program sends registration application information tothe Push proxy, where the registration application information includesan application program name and a push-acceptable heartbeat signaldelay, and the push-acceptable heartbeat signal delay is a time period,such as 30 seconds, 2400 seconds, or 3600 seconds.

After receiving the registration application information, the Push proxysends corresponding registration request information to the Push server,where the registration request information includes a unique deviceidentifier, the application program name, and the push-acceptableheartbeat signal delay, where the unique device identifier is a devicecode used to identify a device of the Push client, for example, anInternational Mobile Equipment Identity (IMEI), which is a globallyunique electronic serial number granted to each mobile phone afterassembling is completed.

After receiving the registration request information, the Push servergenerates a corresponding push target address identifier, and returnsthe generated push target address identifier to the Push proxy.

After receiving the push target address identifier returned by the Pushserver, the Push proxy returns the push target address identifier to theapplication program, where the application program that successfullyregisters the application information with the Push proxy is the targetapplication.

Referring to FIG. 1, FIG. 1 is a schematic structural diagram of anapparatus for controlling sending of a heartbeat signal according to anembodiment of the present invention. The apparatus for controllingsending of a heartbeat signal may be a push client. As shown in FIG. 1,the apparatus for controlling sending of a heartbeat signal at leastincludes a target push delay acquiring module 101, a target push delaysending module 102, a first receiving module 103, and a firstheartbeat-signal sending module 104.

The target push delay acquiring module 101 is configured to acquire atarget push delay corresponding to all target applications. In aspecific implementation, when a Push connection is established or atarget application is installed or uninstalled, the target push delayacquiring module 101 in the Push client acquires the target push delaycorresponding to all the target applications. Further, optionally, thetarget push delay acquiring module 101 may include a first acquiringunit and a second acquiring unit, where the first acquiring unit isconfigured to, when a quantity of all the target applications is one,acquire a push delay of the target application, and use the push delayof the target application as the target push delay; and the secondacquiring unit is configured to, when a quantity of all the targetapplications is at least two, acquire push delays of all the targetapplications, and use a shortest push delay in all the push delays asthe target push delay.

Optionally, after a push delay attribute parameter of a targetapplication is read, a push delay of the target application is obtained,that is, each target application corresponds to one push delay attributeparameter, and each target application corresponds to one push delay.Push delay attribute parameters of all the target applications in thepush client are read. If there is only one target application, the firstacquiring unit acquires a push delay of the target application, and usesthe acquired push delay of the target application as the target pushdelay; if there are multiple target applications, the second acquiringunit acquires push delays of all the target applications, and performscomparison to obtain a shortest push delay as the target push delay.

The target application may write the push delay attribute parameter intoa static configuration file, where the push delay attribute parameterindicates a heartbeat signal delay range acceptable to the targetapplication, and may be an editable time length in seconds. For example,a push delay attribute parameter of 60 seconds can be written into anANDROID device by using the following statements, that is, by adding thefollowing content to a manifest.xml file in an application package inthe ANDROID device.

<meta-data android:name=“PushDeviateSecond” android:value=“60” ></meta-data>

A PushDeviateSecond attribute value in a configuration file of at leastone target application is read to obtain a push delay of the targetapplication. For example, in an ANDROID device, a Push client acquires,through an operating system interface, a PushDeviateSecond attributevalue of meta-data in a configuration file of a target application.

When there are at least two target applications, push delays of all thetarget applications are acquired, and a shortest push delay in all thepush delays is used as the target push delay. For example, push delaysthat are obtained by reading push delay attribute parameters configuredby four target applications and that correspond to all the targetapplications are as follows: a push delay of a target application A is30 seconds, a push delay of a target application B is 90 seconds, a pushdelay of a target application C is 300 seconds, and a push delay of atarget application D is 3600 seconds; then, a shortest push delay,obtained by comparison, is 30 seconds, and therefore, a target pushdelay acquired by the target push delay acquiring module 101 is 30seconds.

The target push delay sending module 102 is configured to send thetarget push delay acquired by the target push delay acquiring module 101to a push server. In a specific implementation, the target push delayacquired by the target push delay acquiring module 101 is sent to thePush server, and an information format of the target push delay is asfollows.

4-bit 4-bit header 8-bit type of service 16-bit total length (quantityversion length (TOS) of bytes) 16-bit identifier 3-bit flag 13-bitfragment offset 8-bit time to 8-bit protocol 16-bit header checksum live(TTL) 32-bit source IP address 32-bit destination IP address 32-bitPushDeviateSecond value

The first receiving module 103 is configured to receive a correspondingfirst heartbeat signal control time that is returned by the push serveraccording to the received target push delay sent by the target pushdelay sending module 102.

The first heartbeat-signal sending module 104 is configured to send aheartbeat signal to the push server at an interval of the firstheartbeat signal control time according to the first heartbeat signalcontrol time received by the first receiving module 103. In a specificimplementation, the first heartbeat-signal sending module 104 sends theheartbeat signal to the push server at an interval of the firstheartbeat signal control time to maintain a connection; for example, thefirst heartbeat-signal sending module 104 sends, according to a receivedfirst heartbeat signal control time of 60 seconds, a heartbeat signal tothe push server at an interval of 60 seconds.

Further, optionally, the apparatus for controlling sending of aheartbeat signal in this embodiment of the present invention may furtherinclude a sending failure rate reporting module 105, a second receivingmodule 106, and a second heartbeat-signal sending module 107.

The sending failure rate reporting module 105 is configured to report asending failure rate to the push server when detecting that theheartbeat signal fails to be sent. In a specific implementation, whendetecting that the heartbeat signal fails to be sent, the push clientreports the sending failure rate to the push server, where the sendingfailure rate is a quantity of heartbeat signal sending failures within apreset time. In a heartbeat signal sending process, heartbeat signalsending may fail if the heartbeat signal is lost or times out, orheartbeat signal sending may also fail if a connection is disconnecteddue to poor network quality. When the heartbeat signal sending fails,the push client may receive a heartbeat signal sending failure response,and further detects the heartbeat signal sending failure. For example, aformat of the sending failure rate reported to the Push server is asfollows.

4-bit 4-bit header 8-bit type of service 16-bit total length (quantityversion length (TOS) of bytes) 16-bit identifier 3-bit flag 13-bitfragment offset 8-bit time to 8-bit protocol 16-bit header checksum live(TTL) 32-bit source IP address 32-bit destination IP address 32-bitsignal sending failure rate 32-bit network standard type

The second receiving module 106 is configured to receive a secondheartbeat signal control time that is returned by the push serveraccording to the sending failure rate reported by the sending failurerate reporting module 105 and the target push delay sent by the targetpush delay sending module 102, where the second heartbeat signal controltime is shorter than the first heartbeat signal control time. The pushserver returns the acquired second heartbeat signal control time to thepush client, and the second receiving module 106 of the push clientreceives the second heartbeat signal control time returned by the pushserver.

The second heartbeat-signal sending module 107 is configured to send aheartbeat signal to the push server at an interval of the secondheartbeat signal control time according to the second heartbeat signalcontrol time received by the second receiving module 106. In a specificimplementation, the second heartbeat-signal sending module 107 sends theheartbeat signal to the push server at an interval of the secondheartbeat signal control time to maintain a connection. For example, thesecond heartbeat-signal sending module 107 sends, according to areceived second heartbeat signal control time of 45 seconds, a heartbeatsignal to the Push server at an interval of 45 seconds. The secondheartbeat signal control time is a heartbeat signal control time that isre-adjusted after a previous heartbeat signal sending failure, therebymaintaining a Push connection and ensuring stability of the connectionwhen heartbeat signal sending fails due to heartbeat signal loss ortimeout, poor network quality, or the like.

The apparatus for controlling sending of a heartbeat signal provided bythis embodiment of the present invention may determine a first heartbeatsignal control time according to an acquired target push delaycorresponding to all target applications, and the first heartbeat signalcontrol time may be adjusted according to a target application, so thata push client can send a heartbeat signal to a push server at aninterval of the first heartbeat signal control time; and when heartbeatsignal sending fails due to network quality, signal loss, or the like,the push client may further send a heartbeat signal to the Push serveraccording to a received second heartbeat signal control time returned bythe push server; further, a heartbeat signal control time may beadjusted according to network quality or the like, thereby ensuringstability of a Push connection, and further improving timeliness of pushmessage pushing, enhancing user experience, and effectively reducingpower consumption and network data traffic.

Referring to FIG. 2, FIG. 2 is a schematic structural diagram of anotherapparatus for controlling sending of a heartbeat signal according to anembodiment of the present invention. The apparatus for controllingsending of a heartbeat signal may be a push server. As shown in FIG. 2,the apparatus for controlling sending of a heartbeat signal at leastincludes a target push delay receiving module 201, afirst-heartbeat-signal-control-time acquiring module 202, a firstsending module 203, and a first heartbeat-signal receiving module 204.

The target push delay receiving module 201 is configured to receive atarget push delay sent by a push client and corresponding to all targetapplications. In a specific implementation, the target push delayreceiving module 201 receives the target push delay sent by the pushclient and corresponding to all the target applications.

The first-heartbeat-signal-control-time acquiring module 202 isconfigured to acquire a first heartbeat signal control timecorresponding to the target push delay received by the target push delayreceiving module 201. In a specific implementation, when thefirst-heartbeat-signal-control-time acquiring module 202 of the pushserver acquires the first heartbeat signal control time corresponding tothe target push delay, the first-heartbeat-signal-control-time acquiringmodule 202 is configured to acquire the first heartbeat signal controltime according to a network standard, a push success rate, and thetarget push delay, where the first heartbeat signal control time is alongest heartbeat signal control time, corresponding to the target pushdelay, in a current network standard and when a preset push success rateis met.

The push success rate is statistical data that is pre-collected ondifferent target applications by the push server in different networkstandards, where the data corresponds to a push delay and a heartbeatsignal control time of a target application. For example, statisticaldata in the push server may be a chart, where, in this chart, acoordinate system is established by using the push delay and theheartbeat signal control time of the target application as a horizontalaxis and a vertical axis respectively, and a corresponding coordinatepoint is the push success rate. When receiving the target push delay,the push server finds a corresponding longest heartbeat signal controltime in the coordinate system according to the target push delay and apreset push success rate, and acquires the heartbeat signal control timeas the first heartbeat signal control time. For example, a push delay ofa target application A is 30 seconds, a push delay of a targetapplication B is 45 seconds, a push delay of a target application C is60 seconds, a target push delay corresponding to the target applicationsA, B, and C is 30 seconds, and a preset push success rate is 99.9percent (%), a longest heartbeat signal control time corresponding tothe push delay of 30 seconds and the push success rate of 99.9% issearched for in the chart, and the longest heartbeat signal control timeof 60 seconds is found, and then, 60 seconds are determined as the firstheartbeat signal control time.

The first sending module 203 is configured to send the first heartbeatsignal control time acquired by the first-heartbeat-signal-control-timeacquiring module 202 to the push client. In a specific implementation,the first sending module 203 of the push server sends the firstheartbeat signal control time acquired by thefirst-heartbeat-signal-control-time acquiring module 202 to the pushclient. For example, a format of the first heartbeat signal control timesent to the push client is as follows.

4-bit 4-bit header 8-bit type of service 16-bit total length (quantityversion length (TOS) of bytes) 16-bit identifier 3-bit flag 13-bitfragment offset 8-bit time to 8-bit protocol 16-bit header checksum live(TTL) 32-bit source IP address 32-bit destination IP address 32-bitsignal time interval

The first heartbeat-signal receiving module 204 is configured to receivea heartbeat signal that is sent by the push client at an interval of thefirst heartbeat signal control time according to the received firstheartbeat signal control time sent by the first sending module. In aspecific implementation, after receiving the first heartbeat signalcontrol time sent by the first sending module 203, the push client sendsthe heartbeat signal to the push server at an interval of the firstheartbeat signal control time, and the push server receives theheartbeat signal sent by the push client, so as to maintain a Pushconnection.

Further, optionally, the apparatus for controlling sending of aheartbeat signal in this embodiment of the present invention may furtherinclude a sending failure rate receiving module 205, asecond-heartbeat-signal-control-time acquiring module 206, a secondsending module 207, and a second heartbeat-signal receiving module 208.

The sending failure rate receiving module 205 is configured to receive asending failure rate that is reported by the push client after detectingthat the heartbeat signal fails to be sent. In a specificimplementation, when detecting that the heartbeat signal fails to besent, the push client reports the sending failure rate to the Pushserver, and the push server receives the sending failure rate. In aheartbeat signal sending process, heartbeat signal sending may fail ifthe heartbeat signal is lost or times out, or heartbeat signal sendingmay also fail if a connection is disconnected due to poor networkquality. When the heartbeat signal sending fails, the push client mayreceive a heartbeat signal sending failure response.

The second-heartbeat-signal-control-time acquiring module 206 isconfigured to acquire a second heartbeat signal control time thatcorresponds to the sending failure rate received by the sending failurerate receiving module 205 and the target push delay received by thetarget push delay receiving module 201. In a specific implementation,when the second-heartbeat-signal-control-time acquiring module 206acquires the second heartbeat signal control time that corresponds tothe sending failure rate and the target push delay, thesecond-heartbeat-signal-control-time acquiring module 206 is configuredto acquire the second heartbeat signal control time according to anetwork standard, a push success rate, the sending failure rate, and thetarget push delay, where the second heartbeat signal control time is alongest heartbeat signal control time, corresponding to the sendingfailure rate and the target push delay, in a current network standardand when a preset push success rate is met.

The push success rate is statistical data that is pre-collected ondifferent target applications by the push server in different networkstandards, where the data corresponds to a push delay and a heartbeatsignal control time of a target application, and may be recorded andmeasured in a form of a chart. For example, for statistical data in thepush server in the case of poor network quality, a coordinate system isestablished by using the push delay and the heartbeat signal controltime of the target application as a horizontal axis and a vertical axisrespectively, and a corresponding coordinate point is the push successrate. When receiving the target push delay, the push server finds acorresponding longest heartbeat signal control time in the coordinatesystem according to the target push delay and the preset push successrate; combined with the sending failure rate, multiplies the foundheartbeat signal control time by a proportionality coefficient to obtainthe second heartbeat signal control time, where the proportionalitycoefficient is a preset proportionality coefficient corresponding to thesending failure rate, and a correspondence is as follows: a highersending failure rate indicates a lower preset proportionalitycoefficient, and a lower sending failure rate indicates a higher presetproportionality coefficient; and multiplies the found heartbeat signalcontrol time by the proportionality coefficient to obtain the secondheartbeat signal control time, where the second heartbeat signal controltime is shorter than the first heartbeat signal control time. Forexample, a push delay of a target application A is 30 seconds, a pushdelay of a target application B is 45 seconds, a push delay of a targetapplication C is 60 seconds, a target push delay is 30 seconds, a presetpush success rate is 99.9%, a corresponding first heartbeat signalcontrol time found in the chart is 40 seconds, a received sendingfailure rate is 5%, and a corresponding preset proportionalitycoefficient is ¾; then, a second heartbeat signal control time is:40*¾=30 seconds.

It should be noted that this embodiment of the present invention doesnot limit a specific correspondence between the sending failure rate andthe proportionality coefficient; a form of statistical data in the caseof poor network quality and a form of statistical data in the case ofnormal network quality may be the same, but specific numeric values maybe different; the form of the statistical data is not limited to achart; and the statistical data may be updated periodically according toan actual situation.

The second sending module 207 is configured to send the second heartbeatsignal control time acquired by the second-heartbeat-signal-control-timeacquiring module 206 to the push client, where the second heartbeatsignal control time is shorter than the first heartbeat signal controltime. In a specific implementation, the second heartbeat signal controltime acquired by the second-heartbeat-signal-control-time acquiringmodule 206 is sent to the push client, where a format of the secondheartbeat signal control time sent to the push client is as follows.

4-bit 4-bit header 8-bit type of service 16-bit total length (quantityversion length (TOS) of bytes) 16-bit identifier 3-bit flag 13-bitfragment offset 8-bit time to 8-bit protocol 16-bit header checksum live(TTL) 32-bit source IP address 32-bit destination IP address 32-bitsignal time interval

The second heartbeat-signal receiving module 208 is configured toreceive a heartbeat signal that is sent by the push client at aninterval of the second heartbeat signal control time according to thereceived second heartbeat signal control time sent by the second sendingmodule 207. In a specific implementation, the second heartbeat-signalreceiving module 208 receives the heartbeat signal that is sent by thepush client at an interval of the second heartbeat signal control time,so as to maintain a connection, where the second heartbeat signalcontrol time is a heartbeat signal control time that is re-adjustedafter a previous heartbeat signal sending failure, thereby maintaining aPush connection and ensuring stability of the connection when heartbeatsignal sending fails due to heartbeat signal loss or timeout, poornetwork quality, or the like.

The apparatus for controlling sending of a heartbeat signal provided bythis embodiment of the present invention may acquire a first heartbeatsignal control time according to a received target push delaycorresponding to all target applications, and the first heartbeat signalcontrol time may be adjusted according to a target application, so thata heartbeat signal sent by a push client at an interval of the firstheartbeat signal control time is received; and when the heartbeat signalfails to be sent due to network quality, signal loss, or the like, apush server may further return a second heartbeat signal control timeaccording to a sending failure rate and a target push delay, so as toreceive a heartbeat signal that is sent by the push client at aninterval of the second heartbeat signal control time; further, theheartbeat signal control time may be adjusted according to networkquality, or the like, thereby ensuring stability of a Push connection,and further improving timeliness of push message pushing, enhancing userexperience, and effectively reducing power consumption and network datatraffic.

Referring to FIG. 3, FIG. 3 is a schematic structural diagram of asystem for controlling sending of a heartbeat signal according to anembodiment of the present invention. As shown in FIG. 3, the systemincludes a push client 1 and a push server 2, where the push client 1and the push server 2 are connected through an IP network; the pushclient refers to a terminal that subscribes to a Push service duringnetwork registration, for example, a device such as a mobile phone, atablet computer, a digital television terminal, a set top box, or thelike, and the push client includes a Push proxy and at least one targetapplication, where the target application may be, for example, atelephone application of a mobile phone, a game application of a tabletcomputer, or a finance application of a digital television; each devicemay have one Push proxy and at least one target application; and thepush client may include at least one device.

The push client 1, such as the apparatus described in the foregoingembodiment corresponding to FIG. 1, is configured to acquire a targetpush delay corresponding to all target applications; send the targetpush delay to the push server 2; receive a first heartbeat signalcontrol time sent by the push server and corresponding to the targetpush delay; and send a heartbeat signal to the push server at aninterval of the first heartbeat signal control time.

The push server 2, such as the apparatus described in the foregoingembodiment corresponding to FIG. 2, is configured to receive the targetpush delay sent by the push client 1 and corresponding to all the targetapplications; acquire the first heartbeat signal control timecorresponding to the target push delay; send the first heartbeat signalcontrol time to the push client; and receive the heartbeat signal sentby the push client at an interval of the first heartbeat signal controltime.

The following illustrates a specific implementation of a method forcontrolling sending of a heartbeat signal provided by an embodiment ofthe present invention.

FIG. 4 is a flowchart of the method for controlling sending of aheartbeat signal according to this embodiment of the present invention.As shown in the figure, the method for controlling sending of aheartbeat signal at least includes the following steps.

Step S401. A push client acquires a target push delay corresponding toall target applications. In a specific implementation, when a Pushconnection is established or a target application is installed oruninstalled, the Push client acquires the target push delaycorresponding to all the target applications, where the acquiring atarget push delay corresponding to all target applications may include,if a quantity of all the target applications is one, acquiring a pushdelay of the target application, and using the push delay of the targetapplication as the target push delay; or if a quantity of all the targetapplications is at least two, acquiring push delays of all the targetapplications, and using a shortest push delay in all the push delays asthe target push delay.

Optionally, after a push delay attribute parameter of a targetapplication is read, a push delay of the target application is obtained,that is, each target application corresponds to one push delay attributeparameter, and each target application corresponds to one push delay.Push delay attribute parameters of all the target applications in thepush client are read. If there is only one target application, a pushdelay of the target application is acquired, and the acquired push delayof the target application is used as the target push delay; if there aremultiple target applications, push delays of all the target applicationsare acquired, and comparison is performed to obtain a shortest pushdelay as the target push delay.

The target application may write the push delay attribute parameter intoa static configuration file, where the push delay attribute parameterindicates a heartbeat signal delay range acceptable to the targetapplication, and may be an editable time length in seconds. For example,a push delay attribute parameter of 60 seconds can be written into anANDROID device by using the following statements, that is, by adding thefollowing content to a manifest.xml file in an application package inthe ANDROID device.

<meta-data android:name=“PushDeviateSecond” android:value=“60” ></meta-data>

A push delay attribute parameter configured by at least one targetapplication is read to obtain a push delay of the target application,that is, a PushDeviateSecond attribute value in a configuration file ofthe at least one target application is read. For example, in the ANDROIDdevice, the Push client acquires the PushDeviateSecond attribute valueof meta-data in the configuration file of the target application byusing an operating system interface.

When there are at least two target applications, push delays of all thetarget applications are acquired, and a shortest push delay in all thepush delays is used as the target push delay. For example, push delaysthat are obtained by reading push delay attribute parameters configuredby four target applications and that correspond to all the targetapplications are as follows: a push delay of a target application A is30 seconds, a push delay of a target application B is 90 seconds, a pushdelay of a target application C is 300 seconds, and a push delay of atarget application D is 3600 seconds; then, a shortest push delay,obtained by comparison, is 30 seconds, and therefore, an acquired targetpush delay is 30 seconds.

Step S402. The push client sends the target push delay to a push server.

Step S403. The push server receives the target push delay sent by thepush client.

Step S404. The push server acquires a first heartbeat signal controltime corresponding to the target push delay. In a specificimplementation, the acquiring a first heartbeat signal control timecorresponding to the target push delay may include acquiring the firstheartbeat signal control time according to a network standard, a pushsuccess rate, and the target push delay, where the first heartbeatsignal control time is a longest heartbeat signal control time,corresponding to the target push delay, in a current network standardand when a preset push success rate is met.

The push success rate is statistical data that is pre-collected ondifferent target applications by the push server in different networkstandards, where the data corresponds to a push delay and a heartbeatsignal control time of a target application. For example, statisticaldata in the push server may be a chart, where, in this chart, acoordinate system is established by using the push delay and theheartbeat signal control time of the target application as a horizontalaxis and a vertical axis respectively, and a corresponding coordinatepoint is the push success rate. When receiving the target push delay,the push server finds a corresponding longest heartbeat signal controltime in the coordinate system according to the target push delay and apreset push success rate, and acquires the heartbeat signal control timeas the first heartbeat signal control time. For example, a push delay ofa target application A is 30 seconds, a push delay of a targetapplication B is 45 seconds, a push delay of a target application C is60 seconds, a target push delay corresponding to the target applicationsA, B, and C is 30 seconds, and a preset push success rate is 99.9%, alongest heartbeat signal control time corresponding to the push delay of30 seconds and the push success rate of 99.9% is searched for in thechart, and the longest heartbeat signal control time of 60 seconds isfound, and then, 60 seconds are determined as the first heartbeat signalcontrol time.

Step S405. The push server sends the first heartbeat signal control timeto the push client.

Step S406. The push client receives the first heartbeat signal controltime returned by the push server.

Step S407. The push client sends a heartbeat signal to the push serverat an interval of the first heartbeat signal control time. In a specificimplementation, the heartbeat signal is sent to the push server at aninterval of the first heartbeat signal control time, so as to maintain aconnection. For example, according to a received first heartbeat signalcontrol time of 60 seconds, a heartbeat signal is sent to the Pushserver at an interval of 60 seconds.

Step S408. Receive the heartbeat signal that is sent by the push clientat an interval of the first heartbeat signal control time.

Step S409. If it is detected that the heartbeat signal fails to be sent,report a sending failure rate to the push server. In a specificimplementation, in a heartbeat signal sending process, heartbeat signalsending may fail if the heartbeat signal is lost or times out, orheartbeat signal sending may also fail if a connection is disconnecteddue to poor network quality. When the heartbeat signal sending fails,the push client may receive a heartbeat signal sending failure response,and further detects the heartbeat signal sending failure.

Step S410. The push server acquires a second heartbeat signal controltime that corresponds to the sending failure rate and the target pushdelay. In a specific implementation, the acquiring a second heartbeatsignal control time that corresponds to the sending failure rate and thetarget push delay may include acquiring the second heartbeat signalcontrol time according to a network standard, a push success rate, thesending failure rate, and the target push delay, where the secondheartbeat signal control time is a longest heartbeat signal controltime, corresponding to the sending failure rate and the target pushdelay, in a current network standard and when a preset push success rateis met.

The push success rate is statistical data that is pre-collected ondifferent target applications by the push server in different networkstandards, where the data corresponds to a push delay and a heartbeatsignal control time of a target application, and may be recorded andmeasured in a form of a chart. For example, for statistical data in thepush server in the case of poor network quality, a coordinate system isestablished by using the push delay and the heartbeat signal controltime of the target application as a horizontal axis and a vertical axisrespectively, and a corresponding coordinate point is the push successrate. When receiving the target push delay, the push server finds acorresponding longest heartbeat signal control time in the coordinatesystem according to the target push delay and the preset push successrate; combined with the sending failure rate, multiplies the foundheartbeat signal control time by a proportionality coefficient, wherethe proportionality coefficient is a preset proportionality coefficientcorresponding to the sending failure rate, and a correspondence is asfollows: a higher sending failure rate indicates a lower presetproportionality coefficient, and a lower sending failure rate indicatesa higher preset proportionality coefficient; and multiplies the foundheartbeat signal control time by the proportionality coefficient toobtain the second heartbeat signal control time, where the secondheartbeat signal control time is shorter than the first heartbeat signalcontrol time. For example, a push delay of a target application A is 30seconds, a push delay of a target application B is 45 seconds, a pushdelay of a target application C is 60 seconds, a target push delay is 30seconds, a preset push success rate is 99.9%, a corresponding firstheartbeat signal control time found in the chart is 40 seconds, areceived sending failure rate is 5%, and a corresponding presetproportionality coefficient is ¾; then, a second heartbeat signalcontrol time is: 40*3/4=30 seconds.

It should be noted that this embodiment of the present invention doesnot limit a specific correspondence between the sending failure rate andthe proportionality coefficient; a form of statistical data in the caseof poor network quality and a form of statistical data in the case ofnormal network quality may be the same, but specific numeric values maybe different; the form of the statistical data is not limited to achart; and the statistical data may be updated periodically according toan actual situation.

Step S411. The push server sends the second heartbeat signal controltime to the push client, where the second heartbeat signal control timeis shorter than the first heartbeat signal control time.

Step S412. The push client receives the second heartbeat signal controltime returned by the push server.

Step S413. The push client sends a heartbeat signal to the push serverat an interval of the second heartbeat signal control time.

Step S414. The push server receives the heartbeat signal that is sent bythe push client at an interval of the second heartbeat signal controltime. In a specific implementation, the heartbeat signal that is sent bythe push client at an interval of the second heartbeat signal controltime is received, so as to maintain a connection, where the secondheartbeat signal control time is a heartbeat signal control time that isre-adjusted after a previous heartbeat signal sending failure, therebymaintaining a Push connection and ensuring stability of the connectionwhen heartbeat signal sending fails due to heartbeat signal loss ortimeout, poor network quality, or the like.

According to the method for controlling sending of a heartbeat signalprovided by this embodiment of the present invention, a first heartbeatsignal control time may be determined according to an acquired targetpush delay corresponding to all target applications, and the firstheartbeat signal control time may be adjusted according to a targetapplication, so that a push client can send a heartbeat signal to a pushserver at an interval of the first heartbeat signal control time; andwhen heartbeat signal sending fails due to network quality, signal loss,or the like, the push client may further send a heartbeat signal to thePush server according to a received second heartbeat signal control timereturned by the push server; further, a heartbeat signal control timemay be adjusted according to network quality, or the like, therebyensuring stability of a Push connection, and further improvingtimeliness of push message pushing, enhancing user experience, andeffectively reducing power consumption and network data traffic.

FIG. 5 is a schematic structural diagram of a terminal according to anembodiment of the present invention. As shown in FIG. 5, the terminalincludes a first processor 501, a first receiver 502, and a first sender503, and the terminal may be a push client, such as a mobile phone, atablet computer, a digital television terminal, or a set top box.

The first processor 501 is configured to acquire a target push delaycorresponding to all target applications.

The first sender 503, connected to the processor 501, is configured tosend the target push delay to a push server.

The first receiver 502, connected to the first processor 501, isconfigured to receive a first heartbeat signal control time sent by thepush server and corresponding to the target push delay.

The first processor 501 is further configured to send a heartbeat signalto the push server through the first sender at an interval of the firstheartbeat signal control time.

Optionally, when acquiring the target push delay corresponding to allthe target applications, the first processor 501 is configured to, if aquantity of all the target applications is one, acquire a push delay ofthe target application, and use the push delay of the target applicationas the target push delay; or if a quantity of all the targetapplications is at least two, acquire push delays of all the targetapplications, and use a shortest push delay in all the push delays asthe target push delay.

Optionally, the first processor 501 is further configured to, aftersending the heartbeat signal to the push server through the first senderat an interval of the first heartbeat signal control time, if detectingthat the heartbeat signal fails to be sent, report a sending failurerate to the push server through the first sender; the first receiver 502is further configured to receive a second heartbeat signal control timethat is returned by the push server according to the sending failurerate and the target push delay, where the second heartbeat signalcontrol time is shorter than the first heartbeat signal control time;and the first processor 501 is further configured to send a heartbeatsignal to the push server through the first sender at an interval of thesecond heartbeat signal control time.

The processor 501 may be a central processing unit (CPU), anapplication-specific integrated circuit (ASIC), or the like. Theterminal in this embodiment may further include a bus 504. The firstprocessor 501, the first receiver 502, and the first sender 503 may beconnected and communicate with each other by using the bus 504.

The terminal in this embodiment of the present invention may determine afirst heartbeat signal control time according to an acquired target pushdelay corresponding to all target applications, and the first heartbeatsignal control time may be adjusted according to a target application,so that a push client can send a heartbeat signal to a push server at aninterval of the first heartbeat signal control time, so as to maintain aPush connection, thereby ensuring stability of the Push connection,improving timeliness of push information pushing, enhancing userexperience, and effectively reducing power consumption and network datatraffic.

FIG. 6 is a schematic structural diagram of a server according to anembodiment of the present invention. As shown in FIG. 6, the serverincludes a second processor 601, a second receiver 602, and a secondsender 603, where the second receiver 602 is configured to receive atarget push delay sent by a push client and corresponding to all targetapplications; the second processor 601, connected to the second receiver602, is configured to acquire a first heartbeat signal control timecorresponding to the target push delay; and the second sender 603,connected to the second processor 601, is configured to send the firstheartbeat signal control time to the push client, where the secondreceiver 602 is further configured to receive a heartbeat signal that issent by the push client at an interval of the first heartbeat signalcontrol time.

Optionally, the second receiver 602 is further configured to receive asending failure rate that is reported by the push client after detectingthat the heartbeat signal fails to be sent; the second processor 601 isfurther configured to acquire a second heartbeat signal control timethat corresponds to the sending failure rate and the target push delay;the second sender 603 is further configured to send the second heartbeatsignal control time to the push client, where the second heartbeatsignal control time is shorter than the first heartbeat signal controltime; and the second receiver 602 is further configured to receive aheartbeat signal that is sent by the push client at an interval of thesecond heartbeat signal control time.

Optionally, when acquiring the first heartbeat signal control timecorresponding to the target push delay, the second processor 601 isconfigured to acquire the first heartbeat signal control time accordingto a network standard, a push success rate, and the target push delay,where the first heartbeat signal control time is a longest heartbeatsignal control time, corresponding to the target push delay, in acurrent network standard and when a preset push success rate is met.

Optionally, when acquiring the second heartbeat signal control time thatcorresponds to the sending failure rate and the target push delay, thesecond processor 601 is configured to acquire the second heartbeatsignal control time according to a network standard, a push successrate, the sending failure rate, and the target push delay, where thesecond heartbeat signal control time is a longest heartbeat signalcontrol time, corresponding to the sending failure rate and the targetpush delay, in a current network standard and when a preset push successrate is met.

The second processor 601 may be a central processing unit, an ASIC, orthe like. The server in this embodiment may further include a bus 604.The second processor 601, the second receiver 602, and the second sender603 may be connected and communicate with each other by using the bus604.

The server in this embodiment of the present invention may acquire afirst heartbeat signal control time according to a received target pushdelay corresponding to all target applications, and the first heartbeatsignal control time may be adjusted according to a target application,so that a heartbeat signal that is sent by a push client at an intervalof the first heartbeat signal control time can be received, therebyensuring stability of a Push connection, and further improvingtimeliness of push information pushing, enhancing user experience, andeffectively reducing power consumption and network data traffic.

With descriptions of the foregoing embodiments, a person skilled in theart may clearly understand that the present invention may be implementedby hardware, firmware or a combination thereof. When the presentinvention is implemented by software, the foregoing functions may bestored in a computer-readable medium or transmitted as one or moreinstructions or code in the computer-readable medium. Thecomputer-readable medium includes a computer storage medium and acommunications medium, where the communications medium includes anymedium that enables a computer program to be transmitted from one placeto another. The storage medium may be any available medium accessible toa computer. The following provides an example but does not impose alimitation. The computer-readable medium may include a random-accessmemory (RAM), a read-only memory (ROM), an electrically erasableprogrammable read-only memory (EEPROM), a compact disc read-only memory(CD-ROM), or another optical disc storage or a disk storage medium, oranother magnetic storage device, or any other medium that can carry orstore expected program code in a form of an instruction or a datastructure and can be accessed by a computer. In addition, any connectionmay be appropriately defined as a computer-readable medium. For example,if software is transmitted from a website, a server or another remotesource by using a coaxial cable, an optical fiber/cable, a twisted pair,a digital subscriber line (DSL) or wireless technologies such asinfrared ray, radio and microwave, the coaxial cable, opticalfiber/cable, twisted pair, DSL or wireless technologies such as infraredray, radio and microwave are included in fixation of a medium to whichthey belong. For example, a disk and disc used by the present inventionincludes a compact disc (CD), a laser disc, an optical disc, a digitalversatile disc (DVD), a floppy disk and a Blu-ray disc, where the diskgenerally copies data by a magnetic means, and the disc copies dataoptically by a laser means. The foregoing combination should also beincluded in the protection scope of the computer-readable medium.

What is disclosed above is merely exemplary embodiments of the presentinvention, and certainly is not intended to limit the protection scopeof the present invention. Therefore, equivalent variations made inaccordance with the claims of the present invention shall fall withinthe scope of the present invention.

What is claimed is:
 1. A method for controlling sending of a heartbeatsignal, comprising: acquiring a target push delay corresponding to alltarget applications; sending the target push delay to a push server;receiving a first heartbeat signal control time sent by the push serverand corresponding to the target push delay; and sending a heartbeatsignal to the push server at an interval of the first heartbeat signalcontrol time.
 2. The method according to claim 1, wherein acquiring thetarget push delay corresponding to all target applications comprises:when a quantity of all the target applications is one, acquiring a pushdelay of the target application, and using the push delay of the targetapplication as the target push delay; and when the quantity of all thetarget applications is at least two, acquiring push delays of all thetarget applications, and using a shortest push delay in all the pushdelays as the target push delay.
 3. The method according to claim 2,wherein after sending the heartbeat signal to the push server at theinterval of the first heartbeat signal control time, the method furthercomprises: reporting a sending failure rate to the push server when itis detected that the heartbeat signal fails to be sent; receiving asecond heartbeat signal control time that is returned by the push serveraccording to the sending failure rate and the target push delay, whereinthe second heartbeat signal control time is shorter than the firstheartbeat signal control time; and sending a heartbeat signal to thepush server at an interval of the second heartbeat signal control time.4. The method according to claim 1, wherein after sending the heartbeatsignal to the push server at the interval of the first heartbeat signalcontrol time, the method further comprises: reporting a sending failurerate to the push server when it is detected that the heartbeat signalfails to be sent; receiving a second heartbeat signal control time thatis returned by the push server according to the sending failure rate andthe target push delay, wherein the second heartbeat signal control timeis shorter than the first heartbeat signal control time; and sending aheartbeat signal to the push server at an interval of the secondheartbeat signal control time.
 5. A method for controlling sending of aheartbeat signal, comprising: receiving a target push delay sent by apush client and corresponding to all target applications; acquiring afirst heartbeat signal control time corresponding to the target pushdelay; sending the first heartbeat signal control time to the pushclient; and receiving a heartbeat signal that is sent by the push clientat an interval of the first heartbeat signal control time.
 6. The methodaccording to claim 5, wherein after receiving the heartbeat signal thatis sent by the push client at the interval of the first heartbeat signalcontrol time, the method further comprises: receiving a sending failurerate that is reported by the push client after detecting that theheartbeat signal fails to be sent; acquiring a second heartbeat signalcontrol time that corresponds to the sending failure rate and the targetpush delay; sending the second heartbeat signal control time to the pushclient, wherein the second heartbeat signal control time is shorter thanthe first heartbeat signal control time; and receiving a heartbeatsignal that is sent by the push client at an interval of the secondheartbeat signal control time.
 7. The method according to claim 6,wherein acquiring the first heartbeat signal control time correspondingto the target push delay comprises: acquiring the first heartbeat signalcontrol time according to a network standard, a push success rate, andthe target push delay, wherein the first heartbeat signal control timeis a longest heartbeat signal control time, corresponding to the targetpush delay, in a current network standard and when a preset push successrate is met.
 8. The method according to claim 6, wherein acquiring thesecond heartbeat signal control time that corresponds to the sendingfailure rate and the target push delay comprises acquiring the secondheartbeat signal control time according to a network standard, a pushsuccess rate, the sending failure rate, and the target push delay,wherein the second heartbeat signal control time is a longest heartbeatsignal control time, corresponding to the sending failure rate and thetarget push delay, in a current network standard and when a preset pushsuccess rate is met.
 9. The method according to claim 5, whereinacquiring the first heartbeat signal control time corresponding to thetarget push delay comprises acquiring the first heartbeat signal controltime according to a network standard, a push success rate, and thetarget push delay, wherein the first heartbeat signal control time is alongest heartbeat signal control time, corresponding to the target pushdelay, in a current network standard and when a preset push success rateis met.
 10. A terminal, comprising: a first processor; a first receiver;and a first sender, wherein the first processor is configured to acquirea target push delay corresponding to all target applications; whereinthe first sender, connected to the first processor, is configured tosend the target push delay to a push server, wherein the first receiver,connected to the first processor, is configured to receive a firstheartbeat signal control time sent by the push server and correspondingto the target push delay, and wherein the first processor is furtherconfigured to send a heartbeat signal to the push server through thefirst sender at an interval of the first heartbeat signal control time.11. The terminal according to claim 10, wherein when the first processoracquires the target push delay corresponding to all the targetapplications, the first processor is configured to: when a quantity ofall the target applications is one, acquire a push delay of the targetapplication, and use the push delay of the target application as thetarget push delay; and when the quantity of all the target applicationsis at least two, acquire push delays of all the target applications, anduse a shortest push delay in all the push delays as the target pushdelay.
 12. The terminal according to claim 11, wherein the firstprocessor is further configured to, after sending the heartbeat signalto the push server through the first sender at an interval of the firstheartbeat signal control time, when detecting that the heartbeat signalfails to be sent, report a sending failure rate to the push serverthrough the first sender, wherein the first receiver is furtherconfigured to receive a second heartbeat signal control time that isreturned by the push server according to the sending failure rate andthe target push delay, wherein the second heartbeat signal control timeis shorter than the first heartbeat signal control time, and wherein thefirst processor is further configured to send a heartbeat signal to thepush server through the first sender at an interval of the secondheartbeat signal control time.
 13. The terminal according to claim 10,wherein the first processor is further configured to, after sending theheartbeat signal to the push server through the first sender at aninterval of the first heartbeat signal control time, when detecting thatthe heartbeat signal fails to be sent, report a sending failure rate tothe push server through the first sender, wherein the first receiver isfurther configured to receive a second heartbeat signal control timethat is returned by the push server according to the sending failurerate and the target push delay, wherein the second heartbeat signalcontrol time is shorter than the first heartbeat signal control time,and wherein the first processor is further configured to send aheartbeat signal to the push server through the first sender at aninterval of the second heartbeat signal control time.